<?php

class WildlivePHPUnitBaseFunctionalTestCase extends sfPHPUnitBaseFunctionalTestCase
{
  
  public function signIn($browser, $username=null, $password=null) {
    if(is_null($username)) $username = 'System';
    if(is_null($password)) {
      $gen = new PasswordGenerator();
      $password = $gen->generate();
      $user = sfGuardUserTable::getInstance()->findOneByUsername($username);
      $user->setPassword($password);
      $user->save();
    }
    return $browser->get('guard/login')
      ->with('form')->begin()
        ->click('Anmelden', array(
          'signin' => array(
            'username' => $username,
            'password' => $password)))
      ->end();
  }
}